import { IParam } from '../../common';
import { IController } from '../../modules';
import { IViewAbility } from '../../view';
import { ICtrlAbility } from '../ability';
import { ICtrlStore } from '../store';

/**
 * 部件控制器接口
 *
 * @export
 * @interface ICtrlController
 */
export interface ICtrlController<S extends ICtrlStore, A extends ICtrlAbility>
	extends IController<S, A> {
	/**
	 * 部件初始化
	 *
	 * @memberof ICtrlController
	 */
	ctrlInit(params: IParam): void;

	/**
	 * 部件挂载
	 *
	 * @memberof ICtrlController
	 */
	ctrlMounted(): void;

	/**
	 * 部件销毁
	 *
	 * @memberof ICtrlController
	 */
	ctrlDestroy(): void;

	/**
	 * 处理子部件初始化
	 *
	 * @param {string} name
	 * @param {ICtrlAbility} ability
	 * @memberof ICtrlController
	 */
	handleCtrlInit(name: string, ability: ICtrlAbility | IViewAbility): void;

	/**
	 * 处理子部件行为
	 *
	 * @param {string} name 部件名称
	 * @param {string} action 行为标识
	 * @param {IParam[]} data 数据
	 * @memberof ICtrlController
	 */
	handleCtrlAction(name: string, action: string, data: IParam[]): void;

	/**
	 * 处理子部件挂载
	 *
	 * @param {string} name
	 * @param {IParam} data
	 * @memberof ICtrlController
	 */
	handleCtrlMounted(name: string, data: IParam): void;

	/**
	 * 处理子部件销毁
	 *
	 * @param {string} name
	 * @param {IParam} data
	 * @memberof ICtrlController
	 */
	handleCtrlDestroy(name: string, data: IParam): void;

	/**
	 * 刷新当前部件
	 *
	 * @param {IParam} [args]
	 * @memberof ICtrlController
	 */
	refresh(args?: IParam): Promise<boolean>;
}
